﻿using System;
using System.Web.Mvc;
using System.Security.Principal;

namespace BlueSky.Web.Binders
{
    /// <summary>
    ///  IPrincipal binder class.
    /// </summary>
    public class IPrincipalModelBinder : ModelBinderBase
    {
        /// <summary>
        /// Bind IPrincipal.
        /// </summary>
        /// <param name="controllerContext">Controller context.</param>
        /// <param name="bindingContext">Binding context.</param>
        /// <returns>IPrincipal object.</returns>
        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {            
            IPrincipal principal = controllerContext.HttpContext.User;
            return principal;
        }
    }
}
